
#include <stdlib.h>

void		dll_first(t_dll **node)
{
  t_dll		*p_node;
  t_dll		*c_node;

  c_node = *node;
  p_node = c_node->prev;
  while (p_node != NULL)
    {
      p_node = p_node->prev;
      c_node = c_node->prev;
    }
  *node = c_node;
}

void		dll_last(t_dll **node)
{
  t_dll		*n_node;
  t_dll		*c_node;

  c_node = *node;
  n_node = c_node->next;
  while (n_node != NULL)
    {
      n_node = n_node->next;
      c_node = c_node->next;
    }
  *node = c_node;
}

void		dll_prev(t_dll **node)
{
  t_dll		*c_node;

  c_node = *node;
  if (*node != NULL && c_node->prev != NULL)
    *node = c_node->prev;
  else
    dll_last(node);
}

void		dll_next(t_dll **node)
{
  t_dll		*c_node;

  c_node = *node;
  if (*node != NULL && c_node->next != NULL)
    *node = c_node->next;
  else
    dll_first(node);
}
